<template>
	<!-- 头部搜索栏以及词库和分组 -->
	<view class="hdbox">
		<view class="hdflex">
			<view class="left" @click="login">
				<image class="img1" :src="$store.state.user.faceUrl"></image>
				<view class="text1">
					{{$store.state.user.nickName ? $store.state.user.nickName : ($store.state.user.username ? $store.state.user.username:'登录')}}
				</view>
			</view>
			<view class="center" @click="cc">
				<image src="@/static/images/ss.png"></image>
				<text class="text2">查词</text>
			</view>
			<view class="right" @click="ck">
				<view class="text1">词库</view>
				<image src="@/static/images/tushu.png"></image>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "top",
		props:['user1'],
		data() {
			return {
				user:this.user1
			};
		},
		methods: {
			ck() {
				uni.navigateTo({
					animationType: 'slide-in-left',
					url: '/pages/ciku/ciku'
				})
			},
			cc() {
				uni.navigateTo({
					url: '/pages/search/search'
				})
			},
			login(){
				if(!this.$store.state.user.id){
					uni.navigateTo({
						url: '../../pages/login/login'
					})
				}else{
					uni.navigateTo({
						url: '../../pages/XGxingxi/XGxingxi'
					})
				}
			}
		}
	}
</script>

<style scoped>
	.hdbox {
		height: 13vh;
	}

	.hdflex {
		position: fixed;
		z-index: 999;
		top: 0;
		width: 100vw;
		padding-top: 8vh;
		padding-bottom: 2vh;
		box-sizing: border-box;
		background-color: #3F9D83;
		display: flex;
		font-size: 14px;
		justify-content: space-between;
		align-items: center;
	}

	.left,
	.right {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #FFFFFF;
	}

	.center image {
		width: 20px;
		height: 20px;
	}

	.right image{
		width: 30px;
		height: 30px;
	}
	.img1 {
		background-color: #f4f4f4;
		width: 35px;
		height: 35px;
		border-radius: 50%;
	}

	.text1 {
		width: 35px;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
		font-size: 12px;
		text-align: center;
		
	}

	.left .text1 {
		margin-left: 5px;
	}

	.right .text1 {
		margin-right: 5px;

	}

	.text2 {
		margin-left: 5px;
	}

	.center {
		flex: 2;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #ffffff;
		opacity: 0.8;
		border-radius: 15px;
		height: 30px;
		box-sizing: border-box;
	}
</style>
